package com.adb.dao;

import android.database.sqlite.SQLiteDatabase;

public class DBCreate {

	// "-------------------------------------初级------------------------------          ",
	public static String dataEsay[] = new String[] {
			// 1
			"021008050950700012000050004700529080003607500090843001200060000630001048040200360",
			// 2
			"002006100500480093030700420100057000805030206000960004076001080940023005008600300",
			// 3
			"706000080039024006010030905002706040400301002090205700908010060100470850050000403",
			// 4
			"205060017907500800010200049000090170100807002056010000360009050009004603820030704",
			// 5
			"002070106034500009000803004010002503097601480205700090900107000500008260603040900",
			// 6
			"340000508000543009907060200070408030013000980020106050001020804500789000208000065",
			// 7
			"008010230300640700960800001000050620670201094029070000200007053003084002051060900",
			// 8
			"007030600080056090406002301034205000890000067000908530609500103070410020002080700",
			// 9
			"950624003038007061000000050360209008100000006500108072070000000610900830400856097",
			// 10
			"012940060003010407608305000060030002007604100100080050000501708504090200080067390",
			// 11
			"000500008890100200020074300902000030013000860060000109009350020008009015200001000",
			// 12
			"562000189000508000010000040890107054000000000120409073040000020000203000253000718",
			// 13
			"000074680800000000004006910020065071000000000480310050016900800000000009032750000",
			// 14 与 原 25
			"048000060001047000000003509000008030054000690010500000109300000000710900060000410",
			// 15
			"020000090500804002100030008002367100003000400001542900800090006400105009030000070",
			// 16
			"000003009000420010030010070608000003293000156500000402070080040060074000800300000",
			// 17
			"020000080008050100015804620200183005000000000800625001092406730004090200060000050",
			// 18
			"370908054000501000200000009040060010603000402020090030500000006000803000910206047",
			// 19
			"010000070043000520570020031200103009000502000100904005780010092021000360060000050",
			// 20
			"400800037500007910000004080000003020930502041060700000090400000056200003810009005",
			// 21 bao03
			"851000009000260700000501003000000084028930005009000060600014000300780000170020530",
			// 22 bao05
			"070000209000801000050000000060970051400000980000500002803257040500190708120400000",
			// 23 bao12
			"080001600070400021500396000204050130008907500057030900000563009310002050005800040",
			// 24 bao13
			"065000300200067900040300001006050004000402000700080100600004010008570006001000830",
			// 25 bao14
			"900278100001030249003000000030800000007000500000004030000000300578040900004516007",
			// 26 bao15
			"000000004028750030031002000650237000000090000000681059000900860090024310500000000",
			// 27 bao17
			"000090030000860120000342860007000205008000600201000400035276000016084000020050000",
			// 28 bao19
			"000904000092563810600000005500408003070000050200709001700000004014385760000207000",
			// 29 bao20
			"206907000095000630000030200050040001000302000400070060001060000079000180000108409",
			// 30 bao24
			"076000310900050004005608900061070830000000000089010540002307100600090003098000260",
			// 31 bao27
			"002040800950000041000203000060905010700000004030604050000706000470000035006030100", };

	// "-------------------------------------专家-------------------------------------",
	public static String dataExpert[] = new String[] {
			// 21
			"620005300800000050000010700406038000000000000000420809003040000050000004007500091",
			// 22
			"607405080000069050300000000005020100020000060008030400000000009030750000070106208",
			// 23
			"050020600130079000640000009000008000910000084000900000800000053000780092007030040",
			// 24
			"300080007100706002062040980500000001008000300400000008015090230900301005800050009",
			// 25 原14
			"000430005000000160900780000000050876090000010751020000000047001079000000300012600",
			// 26
			"050000040600080002010597030100000004060209080900000007020651070500030001070000020",
			// 27
			"702006000019080000006040700040900020300070008090001050001020800000050610000600902",
			// 28
			"000064000800090000700001000030000009910000048200000010042900003005070002000820000",
			// 29
			"090000280630000097800509000003106700000000000001904800000601008120000039046000020",
			// 30
			"570109063300000007009070500000204000002010700000807000004050100100000009850401032",
			// 31
			"000000000047060950003902400060503040080020060030806010004105700015080290000000000",
			// 32
			"000100020004000078800050301002900043000000000680007100105040006230000800090002000",
			// 33
			"000015800670000000000700913826000000005000600000000429358007000000000057002950000",
			// 34
			"007800000020091600010030700390050000201000803000080096005020060006410080000007300",
			// 35
			"500690040004000903000010705000400009050107030200009000805040000702000100030025004",
			// 36
			"007000100000486000043070860100020004200307001300050008031060920000593000005000400",
			// 37
			"903040005000600100012000608000090080300807004020060000206000430005001000100070802",
			// 38
			"860000031004000600010020070500401003000709000900502007070010060002000300690000012",
			// 39
			"030005000017002305005070090700001003000060000100900006090050600402100950000200040",
			// 40
			"200060900003009008040100000600803001090000040800902007000006050300700400001090006",
			// 41
			"900006050600100000000203800020000038090060070530000010001402000000005007050800002",
			// 42
			"250090007004260008007000004000006050000124000080700000300000800500071600900050071",
			// 43
			"000600040160200080000713000002000839003090200985000100000431000090005027050002000",
			// 44
			"980000002000009604047003500056104000000000000000307840009600480408900000300000016",
			// 45
			"900000030008000091000001508400070003080302040600010002703900000840000600020000004",
			// 46
			"000530000067900020000012040002000071306000502470000900050490000040005690000026000",
			// 47
			"600009001100500070000480300206000030050010090040000207009067000070003009800900004",
			// 48
			"000205070200700800600100500024009007900000005100800490009008004005004002030507000",
			// 49
			"600000051502700000000021070008010060005306900060070800040190000000007406870000003",
			// 50
			"604500008050600190070000005000306071000000000830104000100000040069002010400003902",
			// 51
			"500200000090008006004601030040070100905000602003080040010405300400100020000009004",
			// 52
			"600000080020000001007902004100009300070201040008300005700106500400000030010000008",
			// 53
			"006000300001503700050080060100706003900000007300902001010070030002601900004000500",
			// 54
			"000000706050019200610200000000000401001805300509000000000001037008370040903000000",
			// 55
			"070030000082400063000801090009000310700000006013000700030904000560007230000050080",
			// 56
			"008240090200600040100000000050870001060409030300026070000000009080002007030087200",
			// 57
			"902000401600703008000201000009000100210000053008000900000105000400902006107000805",
			// 58
			"000000000700004800350082100510003600800000009002500017009370041001200003000000000",
			// 59
			"900000004026000080007280930000107500002000400001603000098065100030000890700000002",
			// 60
			"000350008050000071027006000809000000030805020000000406000600390690000010200098000", };

	// -------------------------------------大师-------------------------------------
	public static String dataMaster[] = new String[] {
			// 61
			"100007050040000090006003800460700000000891000000006028007300100010000040090200003",
			// 62
			"029030080100000009003010040000092000900401007000760000060070400200000005030050720",
			// 63
			"030000000740006390002800000050070200100609004007040030000001600095200078000000020",
			// 64
			"002000700450901082000080000000805000100702004000306000000030000860504013004000500",
			// 65
			"009605700420000000003000080500209070040000020070406009090000200000000014008701900",
			// 66
			"070000005800010060005007802006021000020000040000960100309100600080090001200000080",
			// 67
			"003810070000500400000030010020000005350000068600000040080060000004007000090041300",
			// 68
			"207003000900100200460000030030000500000604000008000070050000024002008003000200106",
			// 69
			"080429006460000200030080000004007000000901000000300900000010030001000057800735020",
			// 70
			"009000500200000006041702930090107050000000000080604090074506380900000007008000400",
			// 71
			"807000000000090030020400100006004005190802046700900800003005090060020000000000507",
			// 72
			"050080020040002000003500004700901086000000000910603007100008300000200070090060050",
			// 73
			"040087005080200400000004002070006500000090000006400010200300000007008060300750040",
			// 74
			"000060049000005700200800600000100004036070510700009000009004003007200000150090000",
			// 75
			"000090800890200706000060040000010003020609010300080000080050000105003067003070000",
			// 76
			"900720000070310000003000091600200008080000030200007009860000100000084050000071006",
			// 77
			"560001090008000503000000170000010750000609000093040000042000000805000900070400032",
			// 78
			"000000040007310006040000709000800004080209050200003000702000080900038100050000000",
			// 79
			"000000006000010594000204700030008010502000908070900040009307000154060000700000000",
			// 80
			"940020300000008007000056940600000100400000006007000005073890000800500000002030084",
			// 81
			"004005087003906000020000000700010000508703401000080006000000030000607500350800700",
			// 82
			"000024500400100000030700090100000700056090310009000005090002030000008002002370000",
			// 83
			"000040060006003070040050010007900300010000080009002700050060030090500100070010000",
			// 84
			"005039700604008000030200800500000000067000140000000003008007010000900405009360200",
			// 85
			"500010003070080090006205400400000008009000700100000002004801600030090080600040009",
			// 86
			"050030910020700860000009000004007500070000020005800700000300000087004030063020080",
			// 87
			"000000002600004908000170500170060000003802700000040085006035000702600003400000000",
			// 88
			"906000108000003095000000700000705200500401007007208000001000000640800000709000603",
			// 89
			"500360080081070000003400000000000001040185090600000000000002600000050930090043007",
			// 90
			"700100805005300006090060000000001200040000080003700000000040060200007100906005004",
			// 91
			"080050090500000007001306800009000200800102004003000600002905300700000001060010040",
			// 92
			"000060005000000370086070400060700008090506010200009060008050790074000000100030000",
			// 93
			"080060000001007000090004200003500084805000602470002500007900010000400300000030070",
			// 94
			"006000071000500002400010650080000000007304100000000090072060004900007000610000300",
			// 95
			"601003200003000015000000400890020000000307000000040086006000000720000100008600904",
			// 96
			"130000082500000006098000750000107000050080040000406000069000570200000001480000039",
			// 97
			"080006070001400000690200000000800060908000507010003000000009035000008900020700010",
			// 98
			"031050007070600000208009000009020080000000000010030200000700501000005060600010730",
			// 99
			"000103602700400000008200010200000000071308250000000009090005800000004001503701000",
			// 100
			"000000986000000004010082000800905700070000020006203001000650090100000000938000000", };

	public static void iniDatabase(SQLiteDatabase db) {
		db.beginTransaction();// 显示调用事务,提高插入性能,否则每次插入都会自动开启事务,关闭事务
		System.out.println("create database begin==================");
		try {
			ini_gamedata(db);
			iniTable_GameDratf(db);
			
			db.setTransactionSuccessful();
			System.out.println("create database success==================");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			db.endTransaction();
		}
	}

	public static void ini_gamedata(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS gamedata");

		StringBuilder _sql = new StringBuilder();
		_sql.append("CREATE TABLE IF NOT EXISTS gamedata (");
		_sql.append(" id INTEGER PRIMARY KEY AUTOINCREMENT,");
		_sql.append(" av_id INTEGER,");
		_sql.append(" data_initial TEXT,");
		_sql.append(" data_ing TEXT,");
		_sql.append(" data_finish TEXT,");
		_sql.append(" state INTEGER,"); // 状态,0:未完成,1:已完成
		_sql.append(" grade INTEGER,");
		_sql.append(" time_keeping INTEGER,");
		_sql.append(" time_best INTEGER ) ");
		db.execSQL(_sql.toString());

		// 初级
		for (int l = 0; l < dataEsay.length; l++) {
			StringBuffer sb = new StringBuffer();
			sb.append("insert into gamedata(av_id,data_initial,data_ing,data_finish,time_keeping,time_best,grade,state) ");
			sb.append(" values(").append(l + 1).append(",'")
					.append(dataEsay[l]).append("','','',0,0,1,0)");
			db.execSQL(sb.toString());
		}
		// 专家
		for (int l = 0; l < dataExpert.length; l++) {
			StringBuffer sb = new StringBuffer();
			sb.append("insert into gamedata(av_id,data_initial,data_ing,data_finish,time_keeping,time_best,grade,state) ");
			sb.append(" values(").append(l + 101).append(",'")
					.append(dataExpert[l]).append("','','',0,0,2,0)");
			db.execSQL(sb.toString());
		}
		// 大师
		for (int l = 0; l < dataMaster.length; l++) {
			StringBuffer sb = new StringBuffer();
			sb.append("insert into gamedata(av_id,data_initial,data_ing,data_finish,time_keeping,time_best,grade,state) ");
			sb.append(" values(").append(l + 201).append(",'")
					.append(dataMaster[l]).append("','','',0,0,3,0)");
			db.execSQL(sb.toString());
		}

	}

	// 31000版本数据库更新
	public static void updateAll(SQLiteDatabase db) {
		String sql = "update gamedata set data_initial = '008010230300640700960800001000050620670201094029070000200007053003084002051060900' where data_initial = '008010260300640700960800001000050620670201094029070000200007053003084002051060900'";
		db.execSQL(sql);

		sql = "update gamedata set data_initial = '200060900003009008040100000600803001090000040800902007000006050300700400001090006' where data_initial = '200060900003009008040100000600803001090000040800902007000006050300900400001070006'";
		db.execSQL(sql);
	}

	public static void iniTable_GameDratf(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS GameDraft");

		StringBuilder _sql = new StringBuilder();
		_sql.append("CREATE TABLE IF NOT EXISTS GameDraft (");
		_sql.append(" id INTEGER PRIMARY KEY AUTOINCREMENT,");
		_sql.append(" avID INTEGER,");// avID号
		_sql.append(" num INTEGER,");// 81个数中的序号
		_sql.append(" draft TEXT ) ");// 草稿
		db.execSQL(_sql.toString());
	}

}
